package engine.asset
{
	import engine.graphics.resources.*;
	import flash.geom.*;
	import flash.system.*;
	
	public class RxSpriteSet
	{
		private var m_sheet:RxAssetSpriteSheet;
		private var m_name:String;
		private var m_x:int;
		private var m_y:int;
		private var m_width:int;
		private var m_height:int;
		private var m_gridWidth:int;
		private var m_gridHeight:int;
		private var m_setWidth:int;
		private var m_setHeight:int;
		private var m_frameRect:Rectangle;
		private var m_frames:int;
		private var m_frameTime:Number;
		private var m_xml:XML;
		
		public function RxSpriteSet(sheet:RxAssetSpriteSheet, name:String, x:int, y:int, width:int, height:int, grideWidth:int, gridHeight:int, frameTime:Number, xml:XML)
		{
			this.m_sheet = sheet;
			this.m_name = name;
			this.m_x = x;
			this.m_y = y;
			this.m_width = width;
			this.m_height = height;
			this.m_gridWidth = grideWidth;
			this.m_gridHeight = (gridHeight + grideWidth - 1) / grideWidth;
			this.m_setWidth = this.m_width * this.m_gridWidth;
			this.m_setHeight = this.m_height * this.m_gridHeight;
			this.m_frameRect = new Rectangle();
			this.m_frames = gridHeight;
			this.m_frameTime = frameTime;
			this.m_xml = xml;
			this.GetFrameRect(0);
		}
		
		public function GetFrameRect(rect:int) : Rectangle
		{
			var x_off:* = rect % this.m_gridWidth;
			var y_off:* = rect / this.m_gridWidth;
			this.m_frameRect.x = this.m_x + x_off * this.m_width;
			this.m_frameRect.y = this.m_y + y_off * this.m_height;
			this.m_frameRect.width = this.m_width;
			this.m_frameRect.height = this.m_height;
			return this.m_frameRect;
		}
		
		public function get name() : String
		{
			return this.m_name;
		}
		
		public function get x() : int
		{
			return this.m_x;
		}
		
		public function get y() : int
		{
			return this.m_y;
		}
		
		public function get width() : int
		{
			return this.m_width;
		}
		
		public function get height() : int
		{
			return this.m_height;
		}
		
		public function get gridWidth() : int
		{
			return this.m_gridWidth;
		}
		
		public function get gridHeight() : int
		{
			return this.m_gridHeight;
		}
		
		public function get setWidth() : int
		{
			return this.m_setWidth;
		}
		
		public function get setHeight() : int
		{
			return this.m_setHeight;
		}
		
		public function get frames() : int
		{
			return this.m_frames;
		}
		
		public function get frameTime() : Number
		{
			return this.m_frameTime;
		}
		
		public function get xml() : XML
		{
			return this.m_xml;
		}
	}
}